
//显示推荐基金的数据
function showRecfundData(){
    if(typeof(g_recommendList) != "undefined") {
        var viewData = {};
        for(var index=1; index<=g_recommendList.length; ++index) {
            var fundInfo = null;
            for(var j=0; j<g_fundNavInfo.length; ++j) {
                if(g_fundNavInfo[j].code == g_recommendList[index-1]) {
                    fundInfo = g_fundNavInfo[j];
                    break;
                }
            }
            if(fundInfo == null) {
                continue;
            }

            viewData["fund_code_"+index] = fundInfo.code;
            viewData["fund_name_"+index] = fundInfo.name;
            viewData["fund_date_"+index] = fundInfo.date.substr(0,4)+"-"+fundInfo.date.substr(4,2)+"-"+fundInfo.date.substr(6,2);
            viewData["fund_nav_"+index] = fundInfo.nav;
            viewData["fund_ratio_"+index] = fundInfo.ratio;
            viewData["fund_ratio_class_"+index] = fundInfo.ratio>=0 ? "red" : "green";
            viewData["fund_sratio_"+index] = fundInfo.s_ratio;
            viewData["fund_sratio_class_"+index] = fundInfo.s_ratio>=0 ? "red" : "green";
            viewData["fund_oratio_"+index] = fundInfo.o_ratio;
            viewData["fund_oratio_class_"+index] = fundInfo.o_ratio>=0 ? "red" : "green";
            viewData["fund_tratio_"+index] = fundInfo.t_ratio;
            viewData["fund_tratio_class_"+index] = fundInfo.t_ratio>=0 ? "red" : "green";
            viewData["fund_hratio_"+index] = fundInfo.h_ratio;
            viewData["fund_hratio_class_"+index] = fundInfo.h_ratio>=0 ? "red" : "green";
            viewData["fund_wsy_"+index] = fundInfo.w_sy;
            viewData["fund_wsy_class_"+index] = "red";
            viewData["fund_qsy_class_"+index] = "red";
            viewData["fund_nav_class_"+index] = "red";
            viewData["fund_qsy_"+index] = fundInfo.q_sy;
            viewData["fund_zt_"+index] = "/main/campaign/zt/"+fundInfo.code+"/";
            //认购链接
            viewData["fund_buy_"+index] =    "https://trade.southernfund.com/new/account/login/init?url=%2Fnew%2Ftrade%2Fsubscribe%2Finit%3FmenuId%3D30500%26fundcode%3D"+fundInfo.code;
            //申购链接
            viewData["fund_buy_sg_"+index] = "https://trade.southernfund.com/new/account/login/init?url=%2Fnew%2Ftrade%2Fdeclare%2Finit%3FmenuId%3D30500%26fundcode%3D"+fundInfo.code;
            viewData["fund_nav_page_"+index] = "/new/fundproduct/?action=searchjjjz&fundcode="+fundInfo.code;
            viewData["fund_info_page_"+index] = "/new/fundproduct/?action=searchjjgk&fundcode="+fundInfo.code;
        }

        $("#recommendArea").html(Mustache.render($("#recommendTemplate").text(), viewData));
    }
}

//显示超级现金宝数据
function showSuperxjbDate(){
    if(typeof(g_index_hblist) != "undefined") {
        for(var index=0;index<g_index_hblist.length;++index){
            if(g_index_hblist[index].fundcode=="000719"){
                var date=g_index_hblist[index].fdate;
                var strdate = "（"+date.substr(0,4)+"-"+date.substr(4,2)+"-"+date.substr(6,8)+"）";
                $("#nowdate").html(strdate);

                var qsy = parseFloat(g_index_hblist[index].fqrsyl);
                qsy  = qsy.toFixed(3)+"%";
                $("#bfb").html(qsy);
                var wsy = g_index_hblist[index].fmwfsy;
                if((wsy.length-wsy.indexOf("."))==6){
                    wsy = parseFloat(wsy);
                    wsy  = wsy.toFixed(5);
                }else{
                    wsy = parseFloat(wsy);
                    wsy  = wsy.toFixed(4);
                }
                $("#wfsy").html(wsy);
            }
        }

    }
}

//初始化
function baseInitIndex(){
    showRecfundData();
    showSuperxjbDate();
}

baseInitIndex();